﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;

namespace Taxes.TaxesReport
{
    public partial class Tax_loadedReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!X.IsAjaxRequest)
            {
                InitIndustry();
            }
        }

        public void RadioButtonCheck(object sender, DirectEventArgs args)
        {
            if(rd_industry.Checked)
            {
                InitIndustry();
            }
            if(rd_region.Checked)
            {
                InitRegion();
            }
        }

        private void InitIndustry()
        {
            var bll = new BLL.Report1();
            var dt = DateTime.Now;
            dt = dt-new TimeSpan(32,0,0,0);
            string ny = dt.Year.ToString();
            ny += dt.Month.ToString().Length == 1 ? 0 + dt.Month.ToString() : dt.Month.ToString();
            var list = bll.GetReports(ny,1);
            store.DataSource= list;
            store.DataBind();
        }
        private void InitRegion()
        {
             var dt = DateTime.Now;
            dt = dt-new TimeSpan(32,0,0,0);
            string ny = dt.Year.ToString();
            ny += dt.Month.ToString().Length == 1 ? 0 + dt.Month.ToString() : dt.Month.ToString();
            var bll = new BLL.Report1();
            var list = bll.GetReports(ny, 0);
            store.DataSource= list;
            store.DataBind();
        }
    }
}